package com.github.shiqiyue.learn.thread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 *
 * @author wenyao.wu
 * @date 2019/1/31
 */
public class JoinTest {

    private static final Logger logger = LoggerFactory.getLogger(JoinTest.class);

    /****
     * 主线程等待t1执行完毕再执行
     * @param args
     */
    public static void main(String[] args) {
        logger.info("main run");
        Thread t1 = new Thread(() -> {
            logger.info("t1 run");
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
            logger.info("t1 stop");
        });
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        logger.info("main stop");


    }

}
